package com.magic.smartcity.view.more.adapters

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.magic.smartcity.R
import com.magic.smartcity.beans.ParkRecordBean
import com.magic.smartcity.databinding.ItemParkRecordListBinding

/**
 * @description:
 * @create: Create by Magic on 2022/2/23.
 */
class ParkRecordListAdapter: RecyclerView.Adapter<ParkRecordListAdapter.ItemHolder>() {
    private val list:MutableList<ParkRecordBean> = mutableListOf()
    fun setData(data:List<ParkRecordBean>){
        list.clear()
        list.addAll(data)
        notifyDataSetChanged()
    }
    class ItemHolder(binding: ItemParkRecordListBinding) :RecyclerView.ViewHolder(binding.root){
        val binding = binding
    }

    private val TAG: String = "ParkRecordListAdapter"
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
        val inflate = DataBindingUtil.inflate<ItemParkRecordListBinding>(
            LayoutInflater.from(parent.context),
            R.layout.item_park_record_list,
            parent,
            false
        )
        return ItemHolder(inflate)
    }

    override fun onBindViewHolder(holder: ItemHolder, position: Int) {
        holder.binding.parkRecordDetail = list[position]
    }

    override fun getItemCount()=list.size
}